package com.meilai.project.mapper.personnel.org;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.meilai.project.entity.personnel.org.Role;
import com.meilai.project.vo.personnel.org.WebRoleVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author 张驰
 * @date 2020/9/11 13:12
 */
@Mapper
public interface RoleMapper extends BaseMapper<Role> {

    @Select("SELECT DISTINCT r.`name` " +
            "FROM role r " +
            "JOIN user_role_relation urr ON r.id=urr.role_id " +
            "WHERE r.deleted_at IS NULL AND r.`status`=1 AND urr.user_id=#{user_id} " +
            "ORDER BY r.sort,r.id")
    List<String> getUserRoles(@Param("user_id") Long user_id);

    List<WebRoleVO> selectPageList(Page<WebRoleVO> page, @Param("name") String name, @Param("status") Integer status);

    List<WebRoleVO> selectOptionList();
}
